" Preamble {{{
" ==============================================================================
"        File: vimrc
" ------------------------------------------------------------------------------
"     Authors: Alexander Shukaev <AlexanderShukaev@gmail.com>
" ------------------------------------------------------------------------------
" Maintainers: Alexander Shukaev <AlexanderShukaev@gmail.com>
" ------------------------------------------------------------------------------
"  Copyrights: (C) 2013, Alexander Shukaev <AlexanderShukaev@gmail.com>
" ------------------------------------------------------------------------------
"     License: This program is free software: you can redistribute it and/or
"              modify it under the terms of the GNU General Public License as
"              published by the Free Software Foundation, either version 3 of
"              the License, or (at your option) any later version.
"
"              This program is distributed in the hope that it will be useful,
"              but WITHOUT ANY WARRANTY; without even the implied warranty of
"              MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
"              General Public License for more details.
"
"              You should have received a copy of the GNU General Public License
"              along with this program. If not, see
"              <http://www.gnu.org/licenses/>.
" ==============================================================================
" }}} Preamble

" Functions {{{
" ==============================================================================
function! s:Configuration(path)
  execute
  \ 'runtime'                                                                  .
  \ '!'                                                                        .
  \ ' '                                                                        .
  \ simplify(expand('configurations' . '/' . a:path, 1))
endfunction

function! AddMatch(name, group, pattern)
  let l:name =
  \ 'b:'                                                                       .
  \ 'match_'                                                                   .
  \ a:name

  execute
  \ 'if'                                                                       .
  \ ' '                                                                        .
  \ '!'                                                                        .
  \ 'exists'                                                                   .
  \ '('                                                                        .
  \ Haroogan#Quote(l:name)                                                     .
  \ ')'                                                                        .
  \ ' '                                                                        .
  \ '|'                                                                        .
  \ ' '                                                                        .
  \ 'let'                                                                      .
  \ ' '                                                                        .
  \ l:name                                                                     .
  \ ' '                                                                        .
  \ '='                                                                        .
  \ ' '                                                                        .
  \ 'matchadd'                                                                 .
  \ '('                                                                        .
  \ Haroogan#Quote(a:group)                                                    .
  \ ','                                                                        .
  \ ' '                                                                        .
  \ Haroogan#Quote(a:pattern)                                                  .
  \ ')'                                                                        .
  \ ' '                                                                        .
  \ '|'                                                                        .
  \ ' '                                                                        .
  \ 'endif'
endfunction

function! RemoveMatch(name)
  let l:name =
  \ 'b:'                                                                       .
  \ 'match_'                                                                   .
  \ a:name

  execute
  \ 'silent!'                                                                  .
  \ ' '                                                                        .
  \ 'call'                                                                     .
  \ ' '                                                                        .
  \ 'matchdelete'                                                              .
  \ '('                                                                        .
  \ l:name                                                                     .
  \ ')'                                                                        .
  \ ' '                                                                        .
  \ '|'                                                                        .
  \ ' '                                                                        .
  \ 'unlet'                                                                    .
  \ ' '                                                                        .
  \ l:name
endfunction

function! AutoMatch(name, group, pattern, includes, excludes)
  execute
  \ 'autocmd'                                                                  .
  \ ' '                                                                        .
  \ 'FileType'                                                                 .
  \ ' '                                                                        .
  \ join(a:includes, ',')                                                      .
  \ ' '                                                                        .
  \ 'call'                                                                     .
  \ ' '                                                                        .
  \ 'AddMatch'                                                                 .
  \ '('                                                                        .
  \ Haroogan#Quote(a:name)                                                     .
  \ ','                                                                        .
  \ ' '                                                                        .
  \ Haroogan#Quote(a:group)                                                    .
  \ ','                                                                        .
  \ ' '                                                                        .
  \ Haroogan#Quote(a:pattern)                                                  .
  \ ')'

  execute
  \ 'autocmd'                                                                  .
  \ ' '                                                                        .
  \ 'FileType'                                                                 .
  \ ' '                                                                        .
  \ join(a:excludes, ',')                                                      .
  \ ' '                                                                        .
  \ 'call'                                                                     .
  \ ' '                                                                        .
  \ 'RemoveMatch'                                                              .
  \ '('                                                                        .
  \ Haroogan#Quote(a:name)                                                     .
  \ ')'
endfunction

function! Indent()
  call s:Preserve('normal! gg=G')
endfunction

function! RemoveBlank()
  call RemoveBlankBOB()
  call RemoveBlankEOB()
  call RemoveBlankEOL()
endfunction

function! RemoveBlankEOL()
  call s:Preserve('%s/\s\+$//e')
endfunction

function! RemoveBlankBOB()
  call s:Preserve('%s/\%^\(\s*$\n\=\)\+//e')
endfunction

function! RemoveBlankEOB()
  call s:Preserve('%s/\(\s*$\n\=\)\+\%$//e')
endfunction

function! s:SyntaxStack()
  if exists('*synstack')
    echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
  endif
endfunction

function! s:Preserve(command)
  " Save search.
  let l:search = @/

  " Save position.
  let l:position = getpos('.')

  " Save view.
  let l:view = winsaveview()

  " Execute command.
  execute a:command

  " Restore view.
  call winrestview(l:view)

  " Restore position.
  call setpos('.', l:position)

  " Restore search.
  let @/ = l:search
endfunction
" ==============================================================================
" }}} Functions

" Commands {{{
" ==============================================================================
command! SyntaxStack call s:SyntaxStack()
" ==============================================================================
" }}} Commands

" Plugs {{{
" ==============================================================================
noremap <script> <silent> <unique> <Plug>SyntaxStack
\ :SyntaxStack
" ==============================================================================
" }}} Plugs

" Compatibility {{{
" ==============================================================================
" No compatibility with Vi.
let &compatible = 0

" When making a change to one line, don't redisplay the line, but put "$" at
" the end of the changed text.
let &cpoptions = 'aABcefFs$'

" Use Unix, DOS, and Mac file formats, but favor the Unix one for new files.
let &fileformats = 'unix,dos,mac'

" Don't convert backward slashes "\" to forward slashes "/" when expanding file
" paths.
let &shellslash = 0

" NOTE: Don't set `shellslash` if `shell` does not refer to Unix shell. For
" instance, when one is on Windows and one didn't change `shell`, then it
" certainly refers to "cmd.exe" by default. Setting `shellslash` in this case is
" devastating because, for example, `shellescape()` will enclose its arguments
" in single quotes "'" which are not recognized by "cmd.exe" as one could
" expect.

" Enforce Unix convention on Windows: use ".vim" instead of "vimfiles".
if has('win32')
  set runtimepath-=$VIM/vimfiles
  set runtimepath-=$VIM/vimfiles/after

  set runtimepath-=~/vimfiles
  set runtimepath-=~/vimfiles/after

  set runtimepath^=~\.vim
  set runtimepath+=~\.vim\after
endif
" ==============================================================================
" }}} Compatibility

" `Haroogan` {{{
" ==============================================================================
call s:Configuration('Haroogan.vim')
" ==============================================================================
" }}} `Haroogan`

" Cache {{{
" ==============================================================================
" Create directory to store cache.
call Haroogan#CreateDir('~/.cache', 0700)
" ==============================================================================
" }}} Cache

" `viminfo` {{{
" ==============================================================================
" Store "viminfo" in cache.
set viminfo+=n~/.cache/viminfo
" ==============================================================================
" }}} `viminfo`

" Encoding {{{
" ==============================================================================
if has('multi_byte')
  if empty(&termencoding)
    " Encoding for terminal.
    let &termencoding = &encoding
  endif

  " Encoding for buffers, registers, strings in expressions, `viminfo`, etc.
  let &encoding = 'utf-8'

  " Encoding for writing files.
  let &fileencoding = 'utf-8'
endif
" ==============================================================================
" }}} Encoding

" GUI {{{
" ==============================================================================
if has('gui_running')
  " Use console dialogs instead of popup dialogs for simple choices.
  let &guioptions = 'c'

  " Configure font.
  if has('gui_win32')
    let &guifont = 'Powerline Consolas:h12'
  elseif has('gui_gtk')
    let &guifont = 'Powerline Consolas 12'
  endif
endif
" ==============================================================================
" }}} GUI

" Look & Feel {{{
" ==============================================================================
" Display line numbers.
let &number = 1

" Enhance completion in command-line mode.
let &wildmenu = 1

" Ignore non-text files.
let
\ &wildignore =
\ join(
\   [
\     '*.7z',
\     '*.bz2',
\     '*.bzip2',
\     '*.cab',
\     '*.cpio',
\     '*.deb',
\     '*.gz',
\     '*.gzip',
\     '*.iso',
\     '*.lzma',
\     '*.rar',
\     '*.rpm',
\     '*.tar*',
\     '*.tbz',
\     '*.tbz2',
\     '*.tgz',
\     '*.txz',
\     '*.xz',
\     '*.zip',
\     '*.z',
\
\     '*.bmp',
\     '*.gif',
\     '*.jpg',
\     '*.jpeg',
\     '*.png',
\     '*.tga',
\     '*.tiff',
\
\     '*.pdf',
\
\     '*.db',
\
\     '*.a',
\     '*.dll',
\     '*.dylib',
\     '*.exe',
\     '*.lib',
\     '*.o',
\     '*.so',
\
\     '*.class',
\
\     '*.pyc',
\     '*.pyo',
\     '*.pyd',
\
\     '*.elc',
\   ],
\   ','
\ )

" The title of main window is determined by `titlestring`.
let &title = 1

" Format title of main window.
let &titlestring = Haroogan#GetTitle()

" Show status line even if there is only 1 window.
let &laststatus = 2

" Show completion popup menu even when there is only 1 match.
let &completeopt = 'menuone'

" Fold everything by default.
let &foldenable = 1

" Indicate matching brackets when cursor is over them.
let &showmatch = 1

" New windows open to the right of the current one.
let &splitright = 1

" Eliminate redundant redraws.
let &lazyredraw = 1
" ==============================================================================
" }}} Look & Feel

" Navigation {{{
" ==============================================================================
" Don't unload buffer (i.e. don't write file) when it becomes hidden.
let &hidden = 1

" Allow specified keys that move cursor left/right to move to the previous/next
" line when cursor is on the first/last character in the line.
let &whichwrap = 'b,s'

" Allow cursor to be positioned where there is no actual character, but only in
" blockwise visual mode.
let &virtualedit = 'block'

" Keep some lines visible above and below cursor while scrolling vertically.
let &scrolloff = 7

" Keep some columns visible before and after cursor while scrolling
" horizontally.
let &sidescrolloff = 7

" Scroll quarter of the current window height.
autocmd CursorMoved * let &scroll = winheight('.') / 4
" ==============================================================================
" }}} Navigation

" Editing {{{
" ==============================================================================
" Make `<BS>` and `<Del>` behavior less surprising.
let &backspace = 2

" Don't insert 2 spaces after ".", "?", and "!" when joining lines.
let &joinspaces = 0

" Utilize unnamed register `"*` by default for yanking and pasting.
let &clipboard = 'unnamed'

" Set alternative keyboard mapping.
let &keymap = 'russian-qwerty'

" NOTE: Setting `keymap` has side effect of setting `iminsert` to "1", so that
" the specified keyboard mapping becomes effective immediately.

" Intercept side effect of setting `keymap` previously.
let &iminsert = 0

" Use the same `keymap` for search pattern as indicated by `iminsert`.
let &imsearch = -1
" ==============================================================================
" }}} Editing

" Indentation {{{
" ==============================================================================
" Number of spaces that tab counts for when displaying a file.
let &tabstop = 2

" Number of spaces that tab counts for when performing editing operations, like
" inserting tab or using `<BS>`.
let &softtabstop = 0

" Number of spaces to use for each step of (automatic) indentation.
let &shiftwidth = 2

" Use spaces instead of tabs.
let &expandtab = 1

" Smart handling of indentation in the beginning of line.
let &smarttab = 1

" Perform automatic indentation when starting new line.
let &autoindent = 1

" Copy whatever characters were used for indenting on existing line to new line.
let &copyindent = 1

" Amount of indent for continuation line (the one that starts with backward
" slash "\") in Vim scripts (VimL).
let g:vim_indent_cont = 0
" ==============================================================================
" }}} Indentation

" Wrapping {{{
" ==============================================================================
" Don't display non-printable characters.
let &list = 0

" Perform soft text wrapping.
let &wrap = 1

" Wrap at character from `breakat` rather than at the last character that fits
" on screen.
let &linebreak = 1

" Perform hard text wrapping with conventional limit of 80 columns per line.
let &textwidth = 80

" 1. Auto-wrap comments using `textwidth`;
" 2. Recognize numbered lists;
" 3. Allow formatting of comments with `gq`;
" 4. Auto-insert comment leader after hitting `<CR>` in insert mode;
" 5. Auto-wrap text using `textwidth`.
let
\ &formatoptions =
\ join(
\   [
\     'c',
\     'n',
\     'q',
\     'r',
\     't',
\   ],
\   ','
\ )
" ==============================================================================
" }}} Wrapping

" Search {{{
" ==============================================================================
" Wrap around the end of file when searching.
let &wrapscan = 1

" Highlight search matches.
let &hlsearch = 1

" Search interactively as one types.
let &incsearch = 1

" Ignore case in search pattern.
let &ignorecase = 1

" Override `ignorecase` if search pattern contains uppercase letters.
let &smartcase = 1
" ==============================================================================
" }}} Search

" Regular Expressions {{{
" ==============================================================================
" In regular expressions, treat most characters literally, while require
" certain ones to be preceded with backward slash "\" in order to gain special
" meaning.
let &magic = 1
" ==============================================================================
" }}} Regular Expressions

" Spell Checking {{{
" ==============================================================================
" Control spell checking.
autocmd CursorHold  * let &l:spell = 1
autocmd CursorMoved * let &l:spell = 0
autocmd InsertEnter * let &l:spell = 1
autocmd InsertLeave * let &l:spell = 0
autocmd BufWinEnter * let &l:spell = 0
autocmd BufWinLeave * let &l:spell = 0

" Use the following dictionaries for spell checking.
let &spelllang = 'en_us,de_de,ru_ru'
" ==============================================================================
" }}} Spell Checking

" Effects & Sounds {{{
" ==============================================================================
" Enable bells for errors containing messages.
let &errorbells = 1

" Prefer bells instead of screen flashes.
let &visualbell = 0
" ==============================================================================
" }}} Effects & Sounds

" History {{{
" ==============================================================================
" The number of entries to remember for the history of command-line commands
" and search patterns.
let &history = 128
" ==============================================================================
" }}} History

" Backup {{{
" ==============================================================================
" Make backup before overwriting file.
let &writebackup = 1

" Keep backup.
let &backup = 1

" Perform backup by making copy of file and overwriting the original one.
let &backupcopy = 'yes'

" Backup all files.
let &backupskip = ''

" Set directory to store backups.
let &backupdir = expand('$TMP/vim/backup', 1)

" Create directory to store backups.
autocmd BufWritePre * call Haroogan#CreateDir(&backupdir, 0700)

" Prevent collisions in names of backups by appending absolute paths to
" directories containing the originals.
autocmd BufWritePre *
\ let &backupext = '~@' . substitute(expand('%:p:h', 1), '[\\/:]', '%', 'g')
" ==============================================================================
" }}} Backup

" Swap {{{
" ==============================================================================
" Utilize swap.
let &swapfile = 1

" Specify swap interval.
let &updatetime = 2000

" Set directory to store swaps and prevent collisions in names of swaps by using
" absolute paths to files.
let &directory = expand('$TMP/vim/swap', 1) . '//'

" Create directory to store swaps.
call Haroogan#CreateDir(&directory, 0700)
" ==============================================================================
" }}} Swap

" Utilities {{{
" ==============================================================================
" Configure external "grep".
let &grepprg = 'grep --with-filename --line-number $*'

" Utilize internal `:vimgrep`.
let &grepprg = 'internal'
" ==============================================================================
" }}} Utilities

" `pathogen` {{{
" ==============================================================================
call s:Configuration('pathogen.vim')
" ==============================================================================
" }}} `pathogen`

" File Type Detection {{{
" ==============================================================================
" 1. Enable loading plugin files for specific file types;
" 2. Enable loading indent files for specific file types;
" 3. Enable file type detection.
filetype plugin indent on

" If no keywords are found to distinguish between TeX, LaTeX, and ConTeXt, then
" fall back to the LaTeX format by default as it is the most common one.
let g:tex_flavor = 'latex'
" ==============================================================================
" }}} File Type Detection

" Syntax Highlighting / Color Scheme {{{
" ==============================================================================
" Enable syntax highlighting.
syntax on

" NOTE: The file type detection is also used for syntax highlighting. If
" `:syntax on` is invoked, `:filetype on` is invoked implicitly.

" Prefer dark background.
let &background = 'dark'

" Choose color scheme.
colorscheme solarized

" Highlight the line that cursor is in.
let &cursorline = 1

" Highlight column right after `textwidth`.
let &colorcolumn = '+1'

" Highlight blanks.
highlight link BlankIOL CursorLine
highlight      BlankEOL guibg=#FF0000 ctermbg=12
highlight      BlankBOB guibg=#FF0000 ctermbg=12
highlight      BlankEOB guibg=#FF0000 ctermbg=12
highlight      Tab      guibg=#FF0000 ctermbg=12

call
\ AutoMatch(
\   'blank_iol',
\   'BlankIOL',
\   '\S\+\zs\s\{2,}\ze\S\+',
\   ['*'],
\   ['help', 'unite']
\ )

call
\ AutoMatch(
\   'blank_eol',
\   'BlankEOL',
\   '\s\+$',
\   ['*'],
\   ['help', 'unite']
\ )

call
\ AutoMatch(
\   'blank_bob',
\   'BlankBOB',
\   '\%^\(^\s*$\n\=\)\+',
\   ['*'],
\   ['help', 'unite']
\ )

call
\ AutoMatch(
\   'blank_eob',
\   'BlankEOB',
\   '\(^\s*$\n\=\)\+\%$',
\   ['*'],
\   ['help', 'unite']
\ )

call
\ AutoMatch(
\   'tab',
\   'Tab',
\   '\t',
\   ['*'],
\   ['help', 'unite']
\ )

highlight User1 guifg=#FFFFFF guibg=#880000 ctermfg=15 ctermbg=4
highlight User2 guifg=#FFFFFF guibg=#884400 ctermfg=15 ctermbg=6
highlight User3 guifg=#000000 guibg=#CCCC00 ctermfg=0  ctermbg=14
highlight User4 guifg=#000000 guibg=#008800 ctermfg=0  ctermbg=2
highlight User5 guifg=#FFFFFF guibg=#0044FF ctermfg=0  ctermbg=9
highlight User6 guifg=#FFFFFF guibg=#CC00CC ctermfg=0  ctermbg=5

" Highlight Doxygen.
let g:load_doxygen_syntax = 1

" Highlight delimiters in TeX.
let g:plaintex_delimiters = 1
" ==============================================================================
" }}} Syntax Highlighting / Color Scheme

" Hooks {{{
" ==============================================================================
" ==============================================================================
" }}} Hooks

" Mappings {{{
" ==============================================================================
" Configure `<Leader>`.
let mapleader = ' '

" Motion {{{
" ==============================================================================
noremap a <Nop>
noremap b <Nop>
noremap d <Nop>
noremap e <Nop>
noremap h <Nop>
noremap i <Nop>
noremap j <Nop>
noremap k <Nop>
noremap l <Nop>
noremap o <Nop>
noremap q <Nop>
noremap s <Nop>
noremap u <Nop>
noremap w <Nop>
" ------------------------------------------------------------------------------
noremap A <Nop>
noremap B <Nop>
noremap D <Nop>
noremap E <Nop>
noremap H <Nop>
noremap I <Nop>
noremap J <Nop>
noremap K <Nop>
noremap L <Nop>
noremap O <Nop>
noremap Q <Nop>
noremap S <Nop>
noremap U <Nop>
noremap W <Nop>
" ------------------------------------------------------------------------------
noremap <C-a> <Nop>
noremap <C-b> <Nop>
noremap <C-d> <Nop>
noremap <C-e> <Nop>
noremap <C-f> <Nop>
noremap <C-h> <Nop>
noremap <C-j> <Nop>
noremap <C-k> <Nop>
noremap <C-l> <Nop>
noremap <C-s> <Nop>
noremap <C-u> <Nop>
noremap <C-y> <Nop>
" ------------------------------------------------------------------------------
noremap ge <Nop>
noremap gj <Nop>
noremap gk <Nop>
" ------------------------------------------------------------------------------
noremap gE <Nop>
" ------------------------------------------------------------------------------
noremap g<C-a> <Nop>
" ------------------------------------------------------------------------------
noremap zz <Nop>
" ------------------------------------------------------------------------------
noremap ZQ <Nop>
noremap ZZ <Nop>
" ------------------------------------------------------------------------------
noremap <Space> <Nop>
noremap <Up>    <Nop>
noremap <Down>  <Nop>
noremap <Left>  <Nop>
noremap <Right> <Nop>
" ------------------------------------------------------------------------------
noremap <S-Space> <Nop>
noremap <S-Up>    <Nop>
noremap <S-Down>  <Nop>
noremap <S-Left>  <Nop>
noremap <S-Right> <Nop>
" ------------------------------------------------------------------------------
noremap <C-Space> <Nop>
noremap <C-Up>    <Nop>
noremap <C-Down>  <Nop>
noremap <C-Left>  <Nop>
noremap <C-Right> <Nop>
" ==============================================================================
noremap a h
noremap b w
noremap d l
noremap e e
noremap i i
noremap j J
noremap k d
noremap l I
noremap s gj
noremap w gk
" ------------------------------------------------------------------------------
noremap A ^
noremap B b
noremap D $
noremap E ge
noremap I a
noremap J <Up>J
noremap K D
noremap L A
noremap S <C-d>
noremap W <C-u>
" ------------------------------------------------------------------------------
noremap kk dd
" ==============================================================================
" }}} Motion

" Normal {{{
" ==============================================================================
nnoremap <C-r> <Nop>
" ------------------------------------------------------------------------------
nnoremap gh <Nop>
" ------------------------------------------------------------------------------
nnoremap gH <Nop>
" ------------------------------------------------------------------------------
nnoremap g<C-h> <Nop>
" ==============================================================================
nnoremap o o<Esc>
nnoremap u u
" ------------------------------------------------------------------------------
nnoremap O O<Esc>
nnoremap U <C-r>
" ------------------------------------------------------------------------------
nnoremap <silent> <C-n> :bnext<CR>
nnoremap <silent> <C-p> :bprevious<CR>
" nnoremap <C-x> "+x
" nnoremap <C-y> "+y
" nnoremap <C-p> "+p
" ------------------------------------------------------------------------------
nnoremap <Leader>r q
" ------------------------------------------------------------------------------
nnoremap <Leader><Space> za
" ------------------------------------------------------------------------------
nnoremap <Leader><S-Space> zA
" ------------------------------------------------------------------------------
nnoremap <CR> i<CR><Esc>
" ------------------------------------------------------------------------------
nnoremap <S-CR> a<CR><Esc>
" ==============================================================================
" }}} Normal

" Visual {{{
" ==============================================================================
vnoremap o a
vnoremap p "_dP
" ------------------------------------------------------------------------------
" vnoremap <C-x> "+x
" vnoremap <C-y> "+y
" vnoremap <C-p> "+p
" ==============================================================================
" }}} Visual

" Operator-Pending {{{
" ==============================================================================
onoremap o a
" ==============================================================================
" }}} Operator-Pending

" Insert {{{
" ==============================================================================
" NOTE: Pay attention that `<C-h>` is the same as `<BS>` in terminal mode.
" ------------------------------------------------------------------------------
inoremap <C-a> <Nop>
inoremap <C-d> <Nop>
inoremap <C-e> <Nop>
inoremap <C-f> <Nop>
inoremap <C-j> <Nop>
inoremap <C-k> <Nop>
inoremap <C-l> <Nop>
inoremap <C-s> <Nop>
inoremap <C-u> <Nop>
inoremap <C-w> <Nop>
inoremap <C-y> <Nop>
" ------------------------------------------------------------------------------
inoremap <Up>    <Nop>
inoremap <Down>  <Nop>
inoremap <Left>  <Nop>
inoremap <Right> <Nop>
" ------------------------------------------------------------------------------
inoremap <S-Up>    <Nop>
inoremap <S-Down>  <Nop>
inoremap <S-Left>  <Nop>
inoremap <S-Right> <Nop>
" ------------------------------------------------------------------------------
inoremap <C-Up>    <Nop>
inoremap <C-Down>  <Nop>
inoremap <C-Left>  <Nop>
inoremap <C-Right> <Nop>
" ==============================================================================
inoremap <S-CR> <CR><Esc><Up>A
" ------------------------------------------------------------------------------
inoremap <C-Space> <Right>
" ------------------------------------------------------------------------------
inoremap <A-Space> <C-^>
" ==============================================================================
" }}} Insert

" Command-Line {{{
" ==============================================================================
" NOTE: Pay attention that `<C-h>` is the same as `<BS>` in terminal mode.
" ------------------------------------------------------------------------------
cnoremap <C-a> <Nop>
cnoremap <C-d> <Nop>
cnoremap <C-j> <Nop>
cnoremap <C-k> <Nop>
cnoremap <C-l> <Nop>
cnoremap <C-s> <Nop>
" ==============================================================================
cnoremap <C-x> "+x
cnoremap <C-y> "+y
cnoremap <C-p> "+p
" ------------------------------------------------------------------------------
cnoremap <A-Space> <C-^>
" ==============================================================================
" }}} Command-Line
" ==============================================================================
" }}} Mappings

" Configurations {{{
" ==============================================================================
call s:Configuration('MWM.vim')
call s:Configuration('TWM.vim')
call s:Configuration('Uncrustify.vim')
call s:Configuration('NERDCommenter.vim')
call s:Configuration('NERDTree.vim')
call s:Configuration('SameSyntaxMotion.vim')
call s:Configuration('UltiSnips.vim')
call s:Configuration('delimitMate.vim')
call s:Configuration('airline.vim')
call s:Configuration('bufferline.vim')
call s:Configuration('signify.vim')
call s:Configuration('tabular.vim')
call s:Configuration('syntastic.vim')
call s:Configuration('ycm.vim')
call s:Configuration('python.vim')
" call s:Configuration('rainbow.vim')
" call s:Configuration('unite.vim')
" ==============================================================================
" }}} Configurations

" Modeline {{{
" ==============================================================================
" vim:ft=vim:fenc=utf-8:ff=unix:fdm=marker:ts=2:sw=2:tw=80:et:
" ==============================================================================
" }}} Modeline
